package com.glsc.ngateway.common.base.domain.mysql.fileTransfer;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.glsc.ngateway.common.api.common.enums.DictConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author liwei
 * 通用上传文件
 */
@Data
@Entity
@Table(name = "t_common_file")
@org.hibernate.annotations.Table(appliesTo = "t_common_file", comment = "通用上传文件")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CommonFile implements Serializable {
    private static final long serialVersionUID = -365607141666782133L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "file_id", columnDefinition = "varchar(80) COMMENT '文件id'")
    @ApiModelProperty(value = "文件id")
    private String fileId;

    @Column(name = "file_name", columnDefinition = "varchar(400) COMMENT '文件名称'")
    @ApiModelProperty(value = "文件名称")
    private String fileName;

    @Column(name = "file_path", columnDefinition = "varchar(200) COMMENT '文件存储路径'")
    @ApiModelProperty(value = "文件存储路径")
    private String filePath;

    @Column(name = "file_size", columnDefinition = "bigint COMMENT '文件字节数'")
    @ApiModelProperty(value = "文件字节数")
    private Long fileSize;

    @Column(name = "file_desc", columnDefinition = "varchar(200) COMMENT '文件说明信息'")
    @ApiModelProperty(value = "文件说明信息")
    private String fileDesc;

    @ApiModelProperty(value = "文件md5校验码")
    @Column(name = "file_md5", columnDefinition = "varchar(200) COMMENT '文件md5校验码'")
    private String fileMd5;

    @ApiModelProperty(value = "删除状态，字典 YesNo:（N=未删除(默认) Y=已删除)")
    @Column(name = "deleted", columnDefinition = "varchar(20) default 'N' COMMENT '日删除状态，字典 yesno （N=否(默认) Y=是)'")
    protected String deleted= DictConstant.NO;

    @ApiModelProperty(value = "文件状态，字典 YesNo:（Y=启用(默认) N=未启用)")
    @Column(name = "file_status", columnDefinition = "varchar(20) default 'N' COMMENT '文件状态，字典 YesNo:（Y=启用(默认) N=未启用)'")
    protected String fileStatus= DictConstant.YES;

    @ApiModelProperty(value = "数据来源")
    @Column(name = "file_source", columnDefinition = "varchar(32) COMMENT '数据来源'")
    protected String fileSource;

    //创建时间
    @Column(name = "create_time",updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    //todo  是否修改为oa账号
    @ApiModelProperty(value = "创建人oa账号")
    @Column(name = "create_operator", columnDefinition = "varchar(20) COMMENT '创建人oa账号'")
    protected String createOperator;

    @ApiModelProperty(value = "创建人姓名")
    @Column(name = "create_operator_name", columnDefinition = "varchar(100) COMMENT '创建人姓名'")
    protected String createOperatorName;

}
